import rxAjax from '@/assets/js/ajax.js';
import {Util} from '@lowcode/jpaas-common-lib';
import bpmCalCalendarEdit from "./../../../views/modules/bpm/core/BpmCalCalendarEdit";
import bpmCalCalendarTest from "./../../../views/modules/bpm/core/BpmCalCalendarTest";
import BpmCalGrantList from "./../../../views/modules/bpm/core/BpmCalGrantList";


import {I18Parse,CommonLang} from '@lowcode/jpaas-common-lib';
import apiBpmLang from '../../../locales/lang/impl/form/apiBpmLang';
let lang = apiBpmLang;
let i18n=function (langKey,text) {
    return I18Parse.getI18Val(lang.apiBpm,langKey, text)
}

//日历设定 api接口
export const BpmCalSettingApi = {};

BpmCalSettingApi.baseUrl= '/api-bpm/bpm/core/bpmCalSetting';
BpmCalSettingApi.exportUrl= BpmCalSettingApi.baseUrl + '/listExport';

//查询列表
BpmCalSettingApi.query=function (parameter) {
  var url= BpmCalSettingApi.baseUrl + '/query';
  return rxAjax.postJson(url,parameter).then (res => {
    return res.result
  })
}

BpmCalSettingApi.openCalGrant=function(config){
  var baseConf= {
    component:BpmCalGrantList,
    title:i18n('permissAssign','权限分配')
  };
  let conf = { ...baseConf,...config };
  Util.open(conf,function(action){
    return;
  });
};

BpmCalSettingApi.openCalendarTest=function(config){
  var baseConf= {
    component:bpmCalCalendarTest,
    title:i18n('calTest','日历计算测试')
  };
  let conf = { ...baseConf,...config };
  Util.open(conf,function(action){
    return;
  });
};

BpmCalSettingApi.openBpmCalendarEdit=function(config){
  var baseConf= {
    component:bpmCalCalendarEdit,
    title:i18n('calSetting','日历设定')
  };
  let conf = { ...baseConf,...config };
  Util.open(conf,function(action){
    return;
  });
};

/**
* 获取单记录
* @param pkId
* @returns {*}
*/
BpmCalSettingApi.get =function(pkId) {
  var url= BpmCalSettingApi.baseUrl + '/get?pkId=' + pkId;
  return rxAjax.get(url);
}

//保存数据
BpmCalSettingApi.save =function(parameter) {
  var url= BpmCalSettingApi.baseUrl + '/save';
  return rxAjax.postJson(url,parameter);
}

//删除数据
BpmCalSettingApi.del =function(parameter) {
  var url= BpmCalSettingApi.baseUrl + '/del';
  return rxAjax.postUrl(url,parameter);
}

export  default BpmCalSettingApi;

